package com.ruoyi.web.controller.pc.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.blogs.domain.BsBrowseHistory;
import com.ruoyi.blogs.service.IBsBrowseHistoryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "浏览历史")
@RestController
@RequestMapping("/user/history")
public class UserBrowseHistoryController extends BaseController {
  
    @Autowired
    private IBsBrowseHistoryService bsBrowseHistoryService;

    /**
     * 查询浏览历史列表
     */
    @ApiOperation("获取浏览历史列表")
    @GetMapping("/list")
    public TableDataInfo list(BsBrowseHistory bsBrowseHistory){
      startPage();
      bsBrowseHistory.setUserId(SecurityUtils.getUserId());
      List<BsBrowseHistory> list = bsBrowseHistoryService.selectBsBrowseHistoryList(bsBrowseHistory);
      return getDataTable(list);
    }

    /**
     * 删除浏览历史
     */
    @ApiOperation("批量删除浏览历史")
    @DeleteMapping
    public R<Integer> remove(@RequestParam String id)
    {
        return R.ok(bsBrowseHistoryService.deleteBsBrowseHistoryById(id));
    }
}
